<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
    <!-- meta tags start -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="Keywords" content="blinds, premium, mobile, template, HTML, Css"/>
    <meta name="Description" content="Premium mobile HTML/CSS template."/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <script src="${ctx}/js/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="${ctx}/js/bootstrap.min.js"></script>
    <script src="${ctx}/js/commons.js"></script>
    <link href="${ctx}/jquery-validation/1.11.0/jquery.validate.min.css" type="text/css" rel="stylesheet">
    <script src="${ctx}/jquery-validation/1.11.0/jquery.validate.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="${ctx}/simplelightbox/lightbox.css" type="text/css" media="all">
    <script src="${ctx}/simplelightbox/lightbox.js"></script>
    <link href="${ctx}/css/stylemobile.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="${ctx}/css/css.css" rel="stylesheet" type="text/css" media="all" />

    <title>注册</title>
    <style>
        .textA ul li span{
            width: 28%;
            display: inline-block;
            text-align: right;
            float: left;
            margin-top: 2px
        }
        .list ul li {
            text-align: left;
        }
        .list {
            margin-top: 100px;
        }
        .btn {
            margin-top: 40px;
        }
    </style>

    <script type="text/javascript">
        $(function() {
            //获得Cookie中的openId
            var openId = getCookie("openId");
            $("#openId").val(openId);
        });

        function save() {
            var name = $("#name") .val();
            var idNumber = $("#idNumber").val();
            if (name == '' || name == null){
                alert("请输入您的姓名！");
                return;
            }
            if (!regName(name)) {
                alert("真实姓名输入有误！");
                return;
            }
            if (idNumber == '' || idNumber == null){
                alert("请输入您的身份证号！");
                return;
            }
            if(!regIdNumber(idNumber)) {
                alert("身份证号输入有误！");
                return;
            }
            var data = {
                "openId": $("#openId").val(),
                "name":$("#name").val(),
                "idNumber":$("#idNumber").val(),
            };
            console.log(data)
            $.ajax({
                url: "${ctx}/user/register",
                type: "POST",
                data: JSON.stringify(data),
                dataType : "json",
                contentType:"application/json",
                success: function(data) {
                    console.log(data)
                    var res = eval(data);
                    if (res.code == 200){
                        window.location.href='${ctx}/appoint/myAppoint';
                    }else{
                        alert("注册失败！");
                    }
                },
                error: function(text) {}
            });

        }
    </script>
</head>
<body>
<div id="js_article" class="rich_media">
    <div class="rich_media_content" id="js_content">
        <div class="websiteWrapper">
            <div class="headerOuterWrapper">
                <div class="headerWrapper">
                    <span style="color: #fff;">注册</span>
                </div>
            </div>
            <div  class="tab-pane" id="Section2">
            <input type="hidden" id="openId" name="openid">
            <div class="list textA">
                <ul>
                    <li>
                        <span>姓名：</span>
                        <input id="name" name="name" type="text" style="width: 50%;font-size:15px;line-height: 23px;margin-top: 3%;" required>
                    </li>
                    <li><span>身份证号：</span>
                        <input id="idNumber" type="text" name="idNumber" minlength="15" maxlength="18" style="width: 50%;font-size:15px;line-height: 23px;margin-top: 3%;" required>
                    </li>
                </ul>
            </div>
            <div class="btn">
                <input type="button" class="reg" value="确定" onclick="save()">

            </div>
        </div>
    </div>
</div>
</body>
</html>
